var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function o() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((o.prototype = i.prototype), new o()));
      };
    })(),
  AXGemCollectionView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.spaceTime = 0),
        t.btn_gemCollection_back.on(
          Laya.Event.CLICK,
          t,
          t.onGemCollectionBackAction
        ),
        t.label_gemCollectionLV_down.on(
          Laya.Event.CLICK,
          t,
          t.onDidSelectLvAction
        ),
        t.label_gemCollectionLv.on(Laya.Event.CLICK, t, t.onDidSelectLvAction),
        (t.list_gemCollection_select.vScrollBarSkin = ""),
        (t.list_gemCollection_select.selectEnable = !0),
        t.list_gemCollection_select.on(
          Laya.Event.CLICK,
          t,
          t.onListGemCollectionDidCLick
        ),
        (t.list_gemCollection.vScrollBarSkin = ""),
        (t.list_gemCollection.selectEnable = !0),
        t.list_gemCollection.on(
          Laya.Event.CLICK,
          t,
          t.onCollectionListDidClick
        ),
        (t.list_gemCollection.scrollBar.changeHandler = new Handler(
          t,
          t.onLoadMoreSendGoodsData
        )),
        WebSocketService.addListener({
          caller: t,
          code: 1273,
          method: t.onLoadBaoShiListDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1283,
          method: t.onLoadBaoShiHuiShouDataFn,
        }),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showCollectionView = function () {
        return (
          null == this.collectionV && (this.collectionV = new t()),
          WebSocketService.send({ c: 1273, d: { lvl: 1, pageNum: 0 } }),
          (this.collectionV.list_gemCollection_select.visible = !1),
          (this.collectionV.label_gemCollectionLv.text = "1级"),
          (this.collectionV.curLvl = 1),
          (this.collectionV.list_gemCollection.visible = !1),
          (this.collectionV.currentPage = 0),
          (this.collectionV.moneyPrice = "0"),
          this.collectionV
        );
      }),
      (t.prototype.onLoadMoreSendGoodsData = function (e) {
        var t = e / this.list_gemCollection.scrollBar.max,
          i = new Date(),
          o = !1;
        if (
          (i.getTime() - this.spaceTime >= 3e3 && (o = !0),
          1 == t && 0 == this.isloading && o)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            WebSocketService.send({
              c: 1273,
              d: { lvl: this.curLvl, pageNum: this.currentPage },
            }),
            void (this.spaceTime = i.getTime())
          );
      }),
      (t.prototype.onLoadBaoShiListDataFn = function (e) {
        if (0 == e.code) {
          if (this.currentPage >= 1) {
            if (0 == e.list.length) return void this.currentPage--;
            for (o = 0; o < e.list.length; o++) {
              var t = e.list[o];
              this.baoshiArr.push(t), (this.dataSource = []);
            }
          } else
            (this.baoshiArr = e.list),
              (this.dataSource = []),
              this.list_gemCollection_select.scrollTo(0);
          this.baoshiArr.length > 0 &&
            ((this.list_gemCollection.visible = !0),
            (this.moneyPrice = e.more)),
            (this.isloading = !1);
          for (var i, o = 0; o < this.baoshiArr.length; o++) {
            var l = this.baoshiArr[o];
            (i = {
              rec_title: {
                text: l.lvl + "级 " + l.n + "(" + l.t + "+" + l.v + ")",
              },
              image_rec_icon: { skin: "stone/" + l.i + ".png" },
              i: l.i,
              id: l.id,
              lvl: l.lvl,
              n: l.n,
              t: l.t,
              v: l.v,
            }),
              this.dataSource.push(i);
          }
          this.list_gemCollection.dataSource = this.dataSource;
        }
      }),
      (t.prototype.onDidSelectLvAction = function () {
        var e = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"];
        this.resultArr = [];
        for (var t, i = 0; i < e.length; i++)
          (t = { item_bang: { text: e[i] + "级" } }), this.resultArr.push(t);
        (this.list_gemCollection_select.visible = !0),
          (this.list_gemCollection_select.dataSource = this.resultArr);
      }),
      (t.prototype.onListGemCollectionDidCLick = function (e) {
        if ("" != e.target.name && e.target.name) {
          var t = this.list_gemCollection_select.selectedItem;
          (this.list_gemCollection_select.visible = !1),
            (this.label_gemCollectionLv.text = t.item_bang.text);
          var i = this.list_gemCollection_select.selectedIndex + 1;
          WebSocketService.send({
            c: 1273,
            d: { lvl: i, pageNum: this.currentPage },
          }),
            (this.curLvl = i);
        }
      }),
      (t.prototype.onCollectionListDidClick = function (e) {
        if ("" != e.target.name && "btn_recover" == e.target.name) {
          var t = this.list_gemCollection.selectedItem,
            i =
              "您确定以" +
              this.moneyPrice +
              "银回收\n\n" +
              t.lvl +
              "级 " +
              t.n +
              "(" +
              t.t +
              "+" +
              t.v +
              ")?";
          NormalDialog.showNormalDialog(i, this, function () {
            WebSocketService.send({ c: 1283, d: { id: t.id } });
          });
        }
      }),
      (t.prototype.onLoadBaoShiHuiShouDataFn = function (e) {
        if (0 == e.code) {
          WebSocketService.send({
            c: 1273,
            d: { lvl: this.curLvl, pageNum: this.currentPage },
          }),
            Laya.stage.event("HomePageView", "refreshMoney");
          var t = this.list_gemCollection.selectedIndex;
          this.list_gemCollection.deleteItem(t), this.baoshiArr.splice(t, 1);
        }
        ToastView.toastView(e.msg);
      }),
      (t.prototype.onGemCollectionBackAction = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.MarketController.AXGemCollectionViewUI);
